package cloud.xlh.agent;

import com.sun.tools.attach.VirtualMachine;
import com.sun.tools.attach.VirtualMachineDescriptor;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 *
 * @ project name : xlh_osms
 * @ Author: XuLeHuang
 * @ Date: 2023/5/29 19:44
 * @ Description:
 */
public class AttachTest {
    public static void main(String[] args) {
       /* String agentClassPath = args[0];
        String processId = args[1];*/
        List<VirtualMachineDescriptor> list = VirtualMachine.list();
        //todo 判断进程号存不存在，是不是java进程；判断文件是不是存在，是不是jar包
        try {
            VirtualMachine vm= VirtualMachine.attach("9736");
            vm.loadAgent("D:\\development\\environment\\idea\\IdeaProjects\\xlh_osms\\common\\agent\\target\\agent-0.0.1-SNAPSHOT.jar","param");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
